using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour 
{
	public int energy = 5;
	float speed = 0.05f;
	float vLimit = -7.0f;
	
	private Sprite enemySprite;
	
	void Awake()
	{
		enemySprite = new Sprite(3, 1, new Vector2(1,0));
	}
	
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		enemySprite.Animate(this.transform,0,3);
		transform.position -= new Vector3(0, speed, 0);
		if (energy <=0)
		{
			Destroy(this.gameObject);
		}
		OutOfBounds();
	}
	public void TakeDamage (int damage)
	{
		this.energy -= damage;	
	}
	
	public void OutOfBounds()
	{
		if (transform.position.y < vLimit)
		{
		Destroy(this.gameObject);	
		}
	}
}
